package com.iflytek.universitymanagement.prediect;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.springframework.context.annotation.Bean;


@org.springframework.context.annotation.Configuration
public class HBaseConfig {

    @Bean
    public Connection hbaseConnection() throws Exception {
        // 创建 HBase 配置
        Configuration config = HBaseConfiguration.create();

        // 设置 ZooKeeper 地址，使用多个 ZooKeeper 地址以保证高可用
        config.set("hbase.zookeeper.quorum", "hadoop01,hadoop02,hadoop03"); // 替换为实际的 ZooKeeper 地址列表

        // 设置 ZooKeeper 客户端连接端口
        config.set("hbase.zookeeper.property.clientPort", "2181"); // 设置客户端连接端口

        // 返回 HBase 连接
        return ConnectionFactory.createConnection(config);
    }
}

